# ommbot/log.py
#
#

""" bot's logging class """

__copyright__ = 'this file is in the public domain'

import ommbot.generic
import sys, time

class Log(object):

    def __init__(self, loglevel):
        self.loglevel = loglevel

    def log(self, level, module, txt):
        if level >= self.loglevel:
            txt = str(txt)
            sys.stdout.write("[%s] (%s) %s\n" % \
                                 (ommbot.generic.uurminsec(time.time()), \
                                 module, txt))
            sys.stdout.flush()

    def setlevel(self, level):
        self.loglevel = level
